﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QLab.UX.Engine
{
    public class QLabSolution
    {
        public string HomeFolderPath { get; set; }
        public string Name { get; set; }
        public string File 
        {
            get
            {
                return this.Name + ".qlsln";
            }
        }
        public SortedList<string, QLabProject> Projects { get; set; }
        public Dictionary<string, QLabFunction> OpenedFunctions { get; set; }

        public QLabSolution(string homeFolderPath, string name)
        {
            if (!homeFolderPath.EndsWith("\\"))
                homeFolderPath += "\\";
            this.HomeFolderPath = homeFolderPath;
            this.Name = name;
            this.Projects = new SortedList<string, QLabProject>();
            this.OpenedFunctions = new Dictionary<string, QLabFunction>();
        }

        internal void SaveAll()
        {
            foreach (QLabFunction function in this.OpenedFunctions.Values)
            {
                function.Save();
            }
        }
    }
}
